# Name: PackwithPyInstaller.py #
# 
# Author: Zhang Huiyuan #
# Creation Date: 2021.11.17 #
# Version: v0.0.1 #
# 

import os

import Main


# CMD: pyinstaller.exe -F -w -i '.\Icon.ico' -n 'SoftwareName_v0.0.1' '.\Main.py'
def CreatePyInstallerPackingCMD():
	# Get global variables from 'Main.py'.
	Main.CreateGlobalVarialbe()

	# Icon path
	szCurrentDir = os.getcwd()
	szIconPath = '%s/Icons/Icon.ico' %szCurrentDir
	# Target '.spec' name
	szTargetSPECName = '%s_%s' %(Main.g_szSoftwareName, Main.g_szVersionNum)
	# Source '.py' name
	szSourcePYName = '%s\\Main.py' %szCurrentDir

	szPyInstallerPackCMD = 'pyinstaller -F -w -i %s -n %s %s' %(szIconPath, szTargetSPECName, szSourcePYName)
	return szPyInstallerPackCMD


if __name__ == '__main__':
	szPyInstallerPackCMD = CreatePyInstallerPackingCMD()
	print('Current Version: %s_%s\n' %(Main.g_szSoftwareName, Main.g_szVersionNum))
	print(CreatePyInstallerPackingCMD())
	print(os.system(CreatePyInstallerPackingCMD()))